import {loginPath} from './env';
import { Message,Loading} from 'element-ui';    
export default {
	install(Vue){
      //去掉字符串空格
		  
	 	//  Vue.prototype.Trim=(str,is_global)=>{
		// 	var  result;
		//     result = str.replace(/(^\s+)|(\s+$)/g,"");
		//     if(is_global.toLowerCase()=="g"){
		//        result = result.replace(/\s/g,"");
		//      }
		//      return result;
		// }

		//2018-06-15 12:32:58 
		 Vue.prototype.timeDateMinutes=(value)=>{
			// if(value){
				var date = new Date(value);  
				var y = date.getFullYear();    
				var m = date.getMonth() + 1;    
				m = m < 10 ? ('0' + m) : m;    
				var d = date.getDate();    
				d = d < 10 ? ('0' + d) : d;    
				var h = date.getHours();  
				h = h < 10 ? ('0' + h) : h;  
				var minute = date.getMinutes();  
				var second = date.getSeconds();  
				minute = minute < 10 ? ('0' + minute) : minute;    
				second = second < 10 ? ('0' + second) : second;   
				return y + '-' + m + '-' + d+' '+h+':'+minute+':'+second;   
			// }else{
			// 	return '';	
			// }
		}
		Vue.prototype.httpStatusCode=(value)=>{
			if(value.response.status==401){
				window.location.href=loginPath
			}else if(value.response.status==404){
				Message({
					showClose: true,
					message: '程序正在修复中'
				})
			}else{
				return;
			}
		}
	}
}